package com.tsinghua.server.index.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tsinghua.server.common.Result;
import com.tsinghua.server.index.entity.FxjcQuota;
import com.tsinghua.server.index.service.FxjcQuotaService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description:
 * @author: Mr.Eric
 * @create: 2022/3/5 16:48
 */
@RestController
@RequestMapping(value = "/index/")
public class IndexDataController {

    @Resource
    private FxjcQuotaService fxjcQuotaService;


    /**
     * 获取指标列表
     * @param type
     * @return
     */
    @GetMapping(value = "list")
    public Result indexList(@RequestParam(name = "type") String type){
        QueryWrapper<FxjcQuota> query = new QueryWrapper<>();
        query.eq("type",type);
        return Result.succ(fxjcQuotaService.list(query));
    }


    /**
     * 更新指标
     * @param quota
     * @return
     */
    @PostMapping(value = "update")
    public  Result update(@RequestBody FxjcQuota quota){
        return Result.succ(fxjcQuotaService.updateById(quota));
    }



}
